from django.db import models

# Create your models here.
from survey_back import settings


# 用户创建的问卷
class Survey(models.Model):
    text = models.TextField(max_length=4294967295)
    logic = models.TextField(max_length=4294967295, default="{}")
    title = models.TextField(max_length=65535, default='新问卷')
    user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    create_time = models.DateTimeField(auto_now_add=True)
    edit_time = models.DateTimeField(auto_now=True)
    is_active = models.BooleanField(default=False, verbose_name="是否开启问卷")
    setting = models.TextField(default=None, null=True, max_length=4294967295, verbose_name="问卷设置")


# 用户填写的问卷
class SubmitSurvey(models.Model):
    text = models.TextField(max_length=65535)
    user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    survey = models.ForeignKey('Survey', on_delete=models.CASCADE)
    create_time = models.DateTimeField(auto_now_add=True)
    status = models.TextField(max_length=100, default="未审核", verbose_name="审核状态")


class Image(models.Model):
    file = models.ImageField(upload_to="image")
    md5 = models.CharField(max_length=100, default="")


class File(models.Model):
    file = models.FileField(upload_to="file")
    md5 = models.CharField(max_length=100, default="")
